#开发人员：mj
#开发日期：2020/7/25
#开发时间：9:32
#开发环境：PyCharm
import math
import json
class shape():
    '''
    圆面积S=3.14*r*r
    矩形面积S=长*宽
    三角形面积 a b c  p=(a+b+c)/2
    s=sqrt(p(p-a)(p-b)(p-c))
'''
    def __init__(self,*args):
        self.args = [*args]
    def area(self):
        raise NotImplementedError()

class circle(shape):
    def area(self):
        return '{:.2f}'.format(3.14*self.args[0] **2)

class triangle(shape):
    def area(self):
        p = (self.args[0]+self.args[1]+self.args[2])/2
        return '{:.2f}'.format(math.sqrt(p*(p-self.args[0])*(p-self.args[1])*(p-self.args[2])))

class square(shape):
    def area(self):
        return '{:.2f}'.format(self.args[0]*self.args[1])

c = circle(5)
print(c.area())

t = triangle(3,4,5)
print(t.area())

s = square(4,5)
print(s.area())


'''序列化'''
class serialMixIn:
    def serialzation(self):
        return json.dumps(self.area())

class SerCirMixIn(serialMixIn,circle):
    pass
c1=SerCirMixIn(5)
print(c1.__dict__)
print(c1.serialzation())


# 类名都是首字母大写，这个要注意，Shape基类的init，只传入args，感觉有点奇怪
